package top.kaoshanji.p2ch10a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * 代码清单-p2ch10a-318页b：可以进行复制操作的Java类的示例
 * author kaoshanji
 * ^_^
 * create time 2025/2/2 20:04
 */
public class CloneableObject implements Cloneable {

    private static final Logger logger = LogManager.getLogger(CloneableObject.class);

    public static void main(String[] args) throws CloneNotSupportedException {
        logger.info("...代码清单-p2ch10a-318页b：可以进行复制操作的Java类的示例...");

        CloneableObject obj = new CloneableObject();
        obj.clone();

    }

    @Override
    public Object clone() {
        try {
            return super.clone();
        } catch (CloneNotSupportedException e) {
            throw new Error(e); // 不会发生该异常
        }
    }
}
